<?php /*a:6:{s:39:"F:\WWW\youni\view\admin\data\index.html";i:1568169973;s:40:"F:\WWW\youni\view\admin\common\base.html";i:1570370238;s:42:"F:\WWW\youni\view\admin\common\header.html";i:1567752197;s:39:"F:\WWW\youni\view\admin\common\css.html";i:1570602032;s:42:"F:\WWW\youni\view\admin\common\footer.html";i:1567752456;s:38:"F:\WWW\youni\view\admin\common\js.html";i:1570520786;}*/ ?>


    <!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>优你后台</title>

    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->



    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>

<link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="/static/admin/css/animate.css" rel="stylesheet">
<link href="/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
<link href="/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<link href="/static/admin/css/plugins/switchery/switchery.css" rel="stylesheet">
<link href="/static/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">

<link href="/static/admin/css/plugins/fileinput/fileinput.css" rel="stylesheet">
<link href="/static/admin/css/common.css" rel="stylesheet">

<style>
    .table > tbody > tr {
        text-align: center;
    }
    .table tr>th{
        text-align: center;
    }
    .dropdown-menu > .active > a{
        /*background-color:#1ab394;*/
    }
</style>
</head>







<div class="animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>数据库备份（共<?php echo htmlentities($tableNum); ?>张表，共计<?php echo htmlentities($total); ?>）</h5>
            </div>
            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-9 m-b-xs btn-group-sm">
                        <button class="btn btn-outline btn-primary" href="javascript:;" id="export">立即备份</button>
                        <button id="optimize" class="btn btn-outline btn-info " url="<?php echo url('optimize'); ?>" >优化表</button>
                        <button id="repair" class="btn btn-outline btn-danger" url="<?php echo url('repair'); ?>" >修复表</button>
                    </div>
                </div>
                <form id="export-form" method="post" action="<?php echo url('export'); ?>">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>
                                <input class="i-checks checkbox check-all" checked="chedked" type="checkbox">
                            </th>
                            <th>表名</th>
                            <th>数据量</th>
                            <th>数据大小</th>
                            <th>数据引擎</th>
                            <th>编码</th>
                            <th>注释</th>
                            <th>创建时间</th>
                            <th>备份状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php if(!(empty($tables) || (($tables instanceof \think\Collection || $tables instanceof \think\Paginator ) && $tables->isEmpty()))): if(is_array($tables) || $tables instanceof \think\Collection || $tables instanceof \think\Paginator): $i = 0; $__LIST__ = $tables;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                        <tr>
                            <td>
                                <input class="ids i-checks" checked="chedked" type="checkbox" name="ids[]" value="<?php echo htmlentities($vo['name']); ?>">
                            </td>
                            <td><?php echo htmlentities($vo['name']); ?></td>
                            <td>【<?php echo htmlentities($vo['rows']); ?>】 条记录</td>
                            <td><?php echo htmlentities($vo['data_length']); ?></td>
                            <td><?php echo htmlentities($vo['engine']); ?></td>
                            <td><?php echo htmlentities($vo['collation']); ?></td>
                            <td><?php echo htmlentities($vo['comment']); ?></td>
                            <td><?php echo htmlentities($vo['create_time']); ?></td>
                            <td id="info">等待备份...</td>
                            <td>
                                <a class="btn btn-primary btn-xs btn-outline" href="<?php echo url('data/columns',['tables'=>$vo['name']]); ?>">查看</a>

                                <a class="btn btn-primary btn-xs btn-outline" onclick="optimize('<?php echo htmlentities($vo['name']); ?>')">优化表</a>
                                <a class="btn btn-danger btn-xs btn-outline" onclick="repair('<?php echo htmlentities($vo['name']); ?>')">修复表</a>
                            </td>
                        </tr>
                        <?php endforeach; endif; else: echo "" ;endif; else: ?>
                        <td colspan="7" class="text-center"> 暂未发现数据库表! </td>
                        <?php endif; ?>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>



    



    <!-- 全局js -->
<script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/static/admin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/static/admin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/static/admin/js/plugins/layer/layer.min.js"></script>
<script src="/static/admin/js/plugins/iCheck/icheck.min.js"></script>
<script src="/static/admin/js/plugins/switchery/switchery.js"></script><!--IOS开关样式-->

<!-- 自定义js -->
<script src="/static/admin/js/hplus.js?v=4.1.0"></script>
<script src="/static/admin/js/contabs.js"></script>
<script src="/static/admin/js/content.js"></script>

<script src="/static/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/static/admin/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/static/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<!-- 第三方插件 -->
<!--<script src="/static/admin/js/plugins/pace/pace.min.js"></script>-->
<script src="/static/admin/js/plugins/fileinput/fileinput.js"></script>
<script src="/static/admin/js/plugins/fileinput/fileinput_locale_zh.js"></script>
<!-- 欢迎信息 -->
<script src="/static/admin/js/welcome.js"></script>


<script src="/static/admin/js/common.js"></script>

<script src="/static/admin/js/ry-ui.js"></script>
<script>
    $(document).ready(function(){
        $(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green"});
        //IOS开关样式配置
        var elem = document.querySelector('.js-switch');
        var switchery = new Switchery(elem, {
            color: '#1AB394'
        });
        var config = {
            '.chosen-select': {},
        }
    });

</script>



<script>

    //全选的实现
    $('.check-all').on('ifChecked', function (event) {
        $('input[name="ids[]"]').iCheck('check');
    });
    $('.check-all').on('ifUnchecked', function (event) {
        $('input[name="ids[]"]').iCheck('uncheck');
    });
    $(function () {

        (function ($) {
            var $form = $("#export-form"),
                $export = $("#export"),
                tables,
                $optimize = $("#optimize"),
                $repair = $("#repair");

            $optimize.add($repair).click(function () {
                $.post($(this).attr('url'), $form.serialize(), function (data) {
                    if (data.code) {
                        layer.msg(data.msg,{icon:1,time:2000});
                    } else {
                        layer.msg(data.msg,{icon:2,time:2000});
                    }
                });
                return false;
            });

            $export.click(function () {
                $export.parent().children().prop('disabled', true);
                $export.html("正在发送备份请求...");
                $.post(
                    $form.attr("action"),
                    $form.serialize(),
                    function (data) {
                        if (data.code) {
                            tables = data.data.tables;
                            $export.html(data.msg + "开始备份，请不要关闭本页面！");
                            backup(data.data.tab);
                            window.onbeforeunload = function () {
                                return "正在备份数据库，请不要关闭！";
                            };
                        } else {
                            layer.msg(data.msg,{icon:2,time:2000,shade: 0.1,});
                            $export.html("立即备份");
                            setTimeout(function () {
                                $export.parent().children().prop('disabled', false);
                            }, 1500);
                        }
                    });
                return false;
            });

            function backup(tab, status) {
                status && showmsg(tab.id, "开始备份...(0%)");
                $.get($form.attr("action"), tab, function (data) {
                    if (data.code) {
                        showmsg(tab.id, data.msg);
                        if (!$.isPlainObject(data.data.tab)) {
                            $export.parent().children().prop('disabled', false);
                            $export.html("备份完成，点击重新备份");
                            window.onbeforeunload = function () {
                                return null;
                            };
                            return;
                        }
                        backup(data.data.tab, tab.id != data.data.tab.id);
                    } else {
                        layer.msg(data.msg, 0);
                        $export.html("立即备份");
                        setTimeout(function () {
                            $export.parent().children().prop('disabled', false);
                        }, 1500);
                    }
                });
            }



            function showmsg(id, msg) {
                console.log($form.find("input[value=" + tables[id] + "]").closest("tr").find("#info").text);
                $form.find("input[value=" + tables[id] + "]").closest("tr").find("#info").html(msg);
            }
        })(jQuery);

    });

    function optimize(ids) {
        $.post("<?php echo url('data/optimize'); ?>",{ids:ids},function (res) {
            if(res.code){
                layer.msg(res.msg,{icon:1,time:2000});
            }else{
                layer.msg(res.msg,{icon:2,time:2000});
            }
        })
    }
    function repair(ids) {
        $.post("<?php echo url('data/repair'); ?>",{ids:ids},function (res) {
            if(res.code){
                layer.msg(res.msg,{icon:1,time:2000});
            }else{
                layer.msg(res.msg,{icon:2,time:2000});
            }
        })
    }
</script>
